define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {

    var Controller = {
        index: function () {
            // 初始化表格参数配置
            Table.api.init({
                extend: {
                    index_url: 'fangwu/index' + location.search,
                    add_url: 'fangwu/add',
                    edit_url: 'fangwu/edit',
                    del_url: 'fangwu/del',
                    detail_url: 'fangwu/detail',
                    multi_url: 'fangwu/multi',
                    table: 'fangwu',
                }
            });

            var table = $("#table");

            // 初始化表格
            table.bootstrapTable({
                url: $.fn.bootstrapTable.defaults.extend.index_url,
                pk: 'id',
                sortName: 'id',
                columns: [
                    [
                        {checkbox: true},
                        {field: 'id', title: __('Id')},
                        {field: 'xq_name', title: __('Xq_name')},
                        {field: 'fang_no', title: __('Fang_no')},
                        {field: 'area', title: __('Area')},
                        {field: 'fangxing', title: __('Fangxing')},
                        {field: 'zxlx', title: __('Zxlx'), searchList: {"1":__('Zxlx 1'),"2":__('Zxlx 2'),"3":__('Zxlx 3'),"4":__('Zxlx 4')}, formatter: Table.api.formatter.normal},
                        {field: 'fwlx', title: __('Fwlx'), searchList: {"1":__('Fwlx 1'),"2":__('Fwlx 2'),"3":__('Fwlx 3')}, formatter: Table.api.formatter.normal},
                        {field: 'tel', title: __('Tel')},
                        {field: 'ysdz', title: __('Ysdz')},
                        {field: 'bak', title: __('Bak')},
                        {field: 'xxgz1', title: __('Xxgz1')},
                        {field: 'xxgz2', title: __('Xxgz2')},
                        {field: 'xxgz3', title: __('Xxgz3')},
                        {field: 'xxgz4', title: __('Xxgz4')},
                        {field: 'createtime', title: __('Createtime'), operate:'RANGE', addclass:'datetimerange', formatter: Table.api.formatter.datetime},
                        {field: 'updatetime', title: __('Updatetime'), operate:'RANGE', addclass:'datetimerange', formatter: Table.api.formatter.datetime},
                        {field: 'operate', title: __('Operate'), table: table,
                         buttons:[
                            {
                            name:'detail',
                            text:'详情',
                            title:'详情',
                            icon:'fa fa_list',
                            classname:'btn btn-xs btn-primary btn-dialog',
                            url:'fangwu/detail'
                            }
                            
                        ],
                        events: Table.api.events.operate, formatter: Table.api.formatter.operate},
                       
                        
                    ]
                ]
            });

            // 为表格绑定事件
            Table.api.bindevent(table);
        },
        add: function () {
            Controller.api.bindevent();
        },
        edit: function () {
            Controller.api.bindevent();
        },
        api: {
            bindevent: function () {
                Form.api.bindevent($("form[role=form]"));
            }
        }
    };
    return Controller;
});